<?php

function returnMessage($code = 1, $message = "", $data = array())
{
    die(json_encode(array(
        "code" => $code,
        "message" => $message,
        "data" => $data
    )));  
}

function setSetting($module, $data)
{
    global $temple_settings;
    $temple_settings[$module] = $data;
}

function decodeRange($range)
{
    $result = explode("|", $range);
    if (sizeof($result) != 2) return -1;
    if (is_int($result[0]) && is_int($result[1])) return -2;
    if ($result[0] >= $result[1]) return -3;
    return $result;
}

function encodeRange($start, $end)
{
    return $start . "|" . $end;
}
